package com.hssy.wululuaplan.controller;


import com.hssy.wululuaplan.common.Result;
import com.hssy.wululuaplan.entity.Course;
import com.hssy.wululuaplan.entity.Student;
import com.hssy.wululuaplan.form.CourseForm;
import com.hssy.wululuaplan.service.CourseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 课程管理 前端控制器
 * </p>
 *
 * @author Mr.Hongtao
 * @since 2024-02-28
 */
@Api(tags = "课程管理")
@RestController
@RequestMapping("/wululuaplan/course")
public class CourseController {

    @Resource
    private CourseService courseService;

    @ApiOperation("查询课程列表")
    @GetMapping("/findCourseList")
    public Result<List<Course>> findCourseList() {
        List<Course> list = courseService.findCourseList();
        return Result.success(list);
    }

    @ApiOperation("根据id查询课程")
    @GetMapping("/findById")
    public Result<Course> findById(@RequestParam(value = "id") Integer id){
        Course course = courseService.getById(id);
        return Result.success(course);
    }

    @ApiOperation("新增课程")
    @PostMapping("/create")
    public Result<String> create(@RequestBody CourseForm form) {
        courseService.create(form);
        return Result.success();
    }

    @ApiOperation("修改课程")
    @PostMapping("/edit")
    public Result<String> edit(@RequestBody CourseForm form) {
        courseService.edit(form);
        return Result.success();
    }

    @ApiOperation("删除课程")
    @PostMapping("/delete")
    public Result<String> delete(Integer id) {
        courseService.delete(id);
        return Result.success();
    }

    @ApiOperation("课程是否排计划了")
    @GetMapping("/coursePlanStatus")
    public Result<Boolean> coursePlanStatus(@RequestParam("courseId") Integer courseId) {
        Boolean status = courseService.coursePlanStatus(courseId);
        return Result.success(status);
    }
}

